home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / perlbuilderev.exe / %MAINDIR% / Editor Scripts / fixindent.pl next >
Encoding:
Text File  |  2001-06-19  |  861 b   |  64 lines

  1. #Editor Script to fix indentation.
  2. # (c) Solutionsoft, 1998
  3.  
  4. #To use:
  5. #Choose Edit | Select ALL than run this editor script.
  6.  
  7. # The current line is in $_.
  8.  
  9. s/(^\ +\t*)(.)/$2/ ;
  10. s/(^\t+\ *)(.)/$2/ ;
  11.  
  12.  
  13. $prefix = "" ;
  14. foreach $i (1 .. $level){$prefix = $prefix."\t";} 
  15.  
  16. if (/\ *\{\ *$/) 
  17.  {
  18.     $level++ ;
  19.  }
  20.  
  21. if (/^\ *\{\ *$/) 
  22.  {
  23.     $level++ ;
  24.     $prefix = $prefix."\t";
  25.  }
  26.  
  27.  
  28. if (/\ *\}\ *$/) 
  29.  {
  30.     $level-- ;
  31.  }
  32.  
  33. if (/\ *\}\ *\#.*/) 
  34.  {
  35.     $level-- ;
  36.  }
  37.  
  38.  
  39. if (/^\ *\}\ *$/) 
  40.  {
  41.     $prefix = "" ;
  42.     foreach $i (1 .. $level){$prefix = $prefix."\t";}
  43.     $level-- ;
  44.  }
  45.  
  46. if (/^\ *\}\ *\#.*/) 
  47.  {
  48.     $prefix = "" ;
  49.     foreach $i (1 .. $level){$prefix = $prefix."\t";}
  50.     $level-- ;
  51.  }
  52.  
  53.  
  54.  
  55. if ($level < 0) {$level = 0} ; 
  56.  
  57. $_ = $prefix.$_ ;
  58.  
  59. #print the result,
  60. #which will replace the selected text in the IDE.
  61. print $_ ;
  62.  
  63.  
  64.